function loadapartment() {
	$.get('api/apartment_get.php', function(data){
		let apartment = JSON.parse(data)['apartment']
		showTable(apartment)
	});
}

function showTable(apartment) {
	let div = $('#apartment')
	for (let i = 0; i < apartment.length; i++) {

		for (let photo = 0; photo < apartment[i].photos ; photo++) {
			// let photos = $('<img class="apartment_photos" src=/photos/'+apartment[i].id+"/"+photo+".jpg>")
			// containerObject.append(photos)
		}

		var str = $('<div class="apartment_container">' +
			 '<div class="apartment_photos">' +
			 	'<img class="apartment_photos" src=/photos/'+apartment[i].id+"/0.jpg>" +
			 '</div>' +
			 '<div class="info1">' +
			 	'<h3 class="apartment_params" id="apartment_price">'+apartment[i].price+'</h3>' +
			 	'<h3 class="apartment_params" id="apartment_room">'+apartment[i].room+'-комнатная</h3>' +
	 		 '</div>' +
			 '<div class="info2">' +
				 '<h1 class="apartment_params" id="apartment_title">'+apartment[i].title+'</h1>' +
				 '<h2 class="apartment_params" id="apartment_address">'+apartment[i].address+'</h2>' +
				 '<h3 class="apartment_params" id="apartment_phone">'+apartment[i].phone+'</h3>' +
				 '<h3 class="apartment_params" id="apartment_telegram">'+apartment[i].telegram+'</h3>' +
				 '<h3 class="apartment_params" id="apartment_whatsapp">'+apartment[i].whatsapp+'</h3>' +
				 '<h3 class="apartment_params" id="apartment_viber">'+apartment[i].viber+'</h3>' +
			 '</div>' +
		 '</div>');

		div.append(str)

	}	
		console.log(typeof title)
		console.log(typeof str)
		console.log(typeof containerObject)
		console.log(typeof div)
		console.log(apartment.length)
}

document.addEventListener('DOMContentLoaded', function () {
  const slider = new ChiefSlider('.slider', {
    loop: true
  });
  const sliderItems = document.querySelector('.slider__items');
  const sliderCounter = document.querySelector('.slider-counter');
  const updateCounter = () => {
    const index = parseInt(sliderItems.querySelector('.slider__item_active').dataset.index) + 1;
    const count = sliderItems.querySelectorAll('.slider__item').length;
    sliderCounter.textContent = `${index}/${count}`;
  }
  updateCounter();
  sliderItems.addEventListener('transitionend', updateCounter);
});